home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / src / linux-headers-2.6.28-15 / include / linux / ipu.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-09-09  |  31.7 KB  |  1,165 lines

  1. /*
  2.  * Copyright 2005-2009 Freescale Semiconductor, Inc.
  3.  */
  4.  
  5. /*
  6.  * The code contained herein is licensed under the GNU Lesser General
  7.  * Public License.  You may obtain a copy of the GNU Lesser General
  8.  * Public License Version 2.1 or later at the following locations:
  9.  *
  10.  * http://www.opensource.org/licenses/lgpl-license.html
  11.  * http://www.gnu.org/copyleft/lgpl.html
  12.  */
  13.  
  14. /*!
  15.  * @defgroup IPU MXC Image Processing Unit (IPU) Driver
  16.  */
  17. /*!
  18.  * @file arch-mxc/ipu.h
  19.  *
  20.  * @brief This file contains the IPU driver API declarations.
  21.  *
  22.  * @ingroup IPU
  23.  */
  24.  
  25. #ifndef __ASM_ARCH_IPU_H__
  26. #define __ASM_ARCH_IPU_H__
  27.  
  28. #include <linux/types.h>
  29. #ifdef __KERNEL__
  30. #include <linux/interrupt.h>
  31. #else
  32. #define bool char
  33. #define irqreturn_t int
  34. #define dma_addr_t int
  35. #define u32 unsigned int
  36. #define __u32 u32
  37. #endif
  38.  
  39. /*!
  40.  * Enumeration of IPU rotation modes
  41.  */
  42. typedef enum {
  43.     /* Note the enum values correspond to BAM value */
  44.     IPU_ROTATE_NONE = 0,
  45.     IPU_ROTATE_VERT_FLIP = 1,
  46.     IPU_ROTATE_HORIZ_FLIP = 2,
  47.     IPU_ROTATE_180 = 3,
  48.     IPU_ROTATE_90_RIGHT = 4,
  49.     IPU_ROTATE_90_RIGHT_VFLIP = 5,
  50.     IPU_ROTATE_90_RIGHT_HFLIP = 6,
  51.     IPU_ROTATE_90_LEFT = 7,
  52. } ipu_rotate_mode_t;
  53.  
  54. /*!
  55.  * Enumeration of Post Filter modes
  56.  */
  57. typedef enum {
  58.     PF_DISABLE_ALL = 0,
  59.     PF_MPEG4_DEBLOCK = 1,
  60.     PF_MPEG4_DERING = 2,
  61.     PF_MPEG4_DEBLOCK_DERING = 3,
  62.     PF_H264_DEBLOCK = 4,
  63. } pf_operation_t;
  64.  
  65. /*!
  66.  * Enumeration of Synchronous (Memory-less) panel types
  67.  */
  68. typedef enum {
  69.     IPU_PANEL_SHARP_TFT,
  70.     IPU_PANEL_TFT,
  71. } ipu_panel_t;
  72.  
  73. /*  IPU Pixel format definitions */
  74. /*  Four-character-code (FOURCC) */
  75. #define fourcc(a, b, c, d)\
  76.         (((__u32)(a)<<0)|((__u32)(b)<<8)|((__u32)(c)<<16)|((__u32)(d)<<24))
  77.  
  78. /*!
  79.  * @name IPU Pixel Formats
  80.  *
  81.  * Pixel formats are defined with ASCII FOURCC code. The pixel format codes are
  82.  * the same used by V4L2 API.
  83.  */
  84.  
  85. /*! @{ */
  86. /*! @name Generic or Raw Data Formats */
  87. /*! @{ */
  88. #define IPU_PIX_FMT_GENERIC fourcc('I', 'P', 'U', '0')    /*!< IPU Generic Data */
  89. #define IPU_PIX_FMT_GENERIC_32 fourcc('I', 'P', 'U', '1')    /*!< IPU Generic Data */
  90. #define IPU_PIX_FMT_LVDS666 fourcc('L', 'V', 'D', '6')    /*!< IPU Generic Data */
  91. #define IPU_PIX_FMT_LVDS888 fourcc('L', 'V', 'D', '8')    /*!< IPU Generic Data */
  92. /*! @} */
  93. /*! @name RGB Formats */
  94. /*! @{ */
  95. #define IPU_PIX_FMT_RGB332  fourcc('R', 'G', 'B', '1')    /*!<  8  RGB-3-3-2    */
  96. #define IPU_PIX_FMT_RGB555  fourcc('R', 'G', 'B', 'O')    /*!< 16  RGB-5-5-5    */
  97. #define IPU_PIX_FMT_RGB565  fourcc('R', 'G', 'B', 'P')    /*!< 1 6  RGB-5-6-5   */
  98. #define IPU_PIX_FMT_RGB666  fourcc('R', 'G', 'B', '6')    /*!< 18  RGB-6-6-6    */
  99. #define IPU_PIX_FMT_BGR666  fourcc('B', 'G', 'R', '6')    /*!< 18  BGR-6-6-6    */
  100. #define IPU_PIX_FMT_BGR24   fourcc('B', 'G', 'R', '3')    /*!< 24  BGR-8-8-8    */
  101. #define IPU_PIX_FMT_RGB24   fourcc('R', 'G', 'B', '3')    /*!< 24  RGB-8-8-8    */
  102. #define IPU_PIX_FMT_BGR32   fourcc('B', 'G', 'R', '4')    /*!< 32  BGR-8-8-8-8  */
  103. #define IPU_PIX_FMT_BGRA32  fourcc('B', 'G', 'R', 'A')    /*!< 32  BGR-8-8-8-8  */
  104. #define IPU_PIX_FMT_RGB32   fourcc('R', 'G', 'B', '4')    /*!< 32  RGB-8-8-8-8  */
  105. #define IPU_PIX_FMT_RGBA32  fourcc('R', 'G', 'B', 'A')    /*!< 32  RGB-8-8-8-8  */
  106. #define IPU_PIX_FMT_ABGR32  fourcc('A', 'B', 'G', 'R')    /*!< 32  ABGR-8-8-8-8 */
  107. /*! @} */
  108. /*! @name YUV Interleaved Formats */
  109. /*! @{ */
  110. #define IPU_PIX_FMT_YUYV    fourcc('Y', 'U', 'Y', 'V')    /*!< 16 YUV 4:2:2 */
  111. #define IPU_PIX_FMT_UYVY    fourcc('U', 'Y', 'V', 'Y')    /*!< 16 YUV 4:2:2 */
  112. #define IPU_PIX_FMT_Y41P    fourcc('Y', '4', '1', 'P')    /*!< 12 YUV 4:1:1 */
  113. #define IPU_PIX_FMT_YUV444  fourcc('Y', '4', '4', '4')    /*!< 24 YUV 4:4:4 */
  114. /* two planes -- one Y, one Cb + Cr interleaved  */
  115. #define IPU_PIX_FMT_NV12    fourcc('N', 'V', '1', '2') /* 12  Y/CbCr 4:2:0  */
  116. /*! @} */
  117. /*! @name YUV Planar Formats */
  118. /*! @{ */
  119. #define IPU_PIX_FMT_GREY    fourcc('G', 'R', 'E', 'Y')    /*!< 8  Greyscale */
  120. #define IPU_PIX_FMT_YVU410P fourcc('Y', 'V', 'U', '9')    /*!< 9  YVU 4:1:0 */
  121. #define IPU_PIX_FMT_YUV410P fourcc('Y', 'U', 'V', '9')    /*!< 9  YUV 4:1:0 */
  122. #define IPU_PIX_FMT_YVU420P fourcc('Y', 'V', '1', '2')    /*!< 12 YVU 4:2:0 */
  123. #define IPU_PIX_FMT_YUV420P fourcc('I', '4', '2', '0')    /*!< 12 YUV 4:2:0 */
  124. #define IPU_PIX_FMT_YUV420P2 fourcc('Y', 'U', '1', '2')    /*!< 12 YUV 4:2:0 */
  125. #define IPU_PIX_FMT_YVU422P fourcc('Y', 'V', '1', '6')    /*!< 16 YVU 4:2:2 */
  126. #define IPU_PIX_FMT_YUV422P fourcc('4', '2', '2', 'P')    /*!< 16 YUV 4:2:2 */
  127. /*! @} */
  128.  
  129. /* IPU Driver channels definitions.    */
  130. /* Note these are different from IDMA channels */
  131. #ifdef CONFIG_MXC_IPU_V1
  132. #define _MAKE_CHAN(num, in, out, sec)    ((num << 24) | (sec << 16) | (out << 8) | in)
  133. #define IPU_CHAN_ID(ch)         (ch >> 24)
  134. #define IPU_CHAN_SEC_DMA(ch)    ((uint32_t) (ch >> 16) & 0xFF)
  135. #define IPU_CHAN_OUT_DMA(ch)    ((uint32_t) (ch >> 8) & 0xFF)
  136. #define IPU_CHAN_IN_DMA(ch)     ((uint32_t) (ch & 0xFF))
  137.  
  138. #else
  139. #define IPU_MAX_CH    32
  140. #define _MAKE_CHAN(num, v_in, g_in, a_in, out) \
  141.     ((num << 24) | (v_in << 18) | (g_in << 12) | (a_in << 6) | out)
  142. #define _MAKE_ALT_CHAN(ch)        (ch | (IPU_MAX_CH << 24))
  143. #define IPU_CHAN_ID(ch)            (ch >> 24)
  144. #define IPU_CHAN_ALT(ch)        (ch & 0x02000000)
  145. #define IPU_CHAN_ALPHA_IN_DMA(ch)    ((uint32_t) (ch >> 6) & 0x3F)
  146. #define IPU_CHAN_GRAPH_IN_DMA(ch)    ((uint32_t) (ch >> 12) & 0x3F)
  147. #define IPU_CHAN_VIDEO_IN_DMA(ch)    ((uint32_t) (ch >> 18) & 0x3F)
  148. #define IPU_CHAN_OUT_DMA(ch)        ((uint32_t) (ch & 0x3F))
  149. #define NO_DMA 0x3F
  150. #define ALT    1
  151. #endif
  152. /*!
  153.  * Enumeration of IPU logical channels. An IPU logical channel is defined as a
  154.  * combination of an input (memory to IPU), output (IPU to memory), and/or
  155.  * secondary input IDMA channels and in some cases an Image Converter task.
  156.  * Some channels consist of only an input or output.
  157.  */
  158. typedef enum {
  159.     CHAN_NONE = -1,
  160. #ifdef CONFIG_MXC_IPU_V1
  161.     CSI_MEM = _MAKE_CHAN(1, 0xFF, 7, 0xFF),    /*!< CSI raw sensor data to memory */
  162.  
  163.     CSI_PRP_ENC_MEM = _MAKE_CHAN(2, 0xFF, 0, 0xFF),    /*!< CSI to IC Encoder PreProcessing to Memory */
  164.     MEM_PRP_ENC_MEM = _MAKE_CHAN(3, 6, 0, 0xFF),    /*!< Memory to IC Encoder PreProcessing to Memory */
  165.     MEM_ROT_ENC_MEM = _MAKE_CHAN(4, 10, 8, 0xFF),    /*!< Memory to IC Encoder Rotation to Memory */
  166.  
  167.     CSI_PRP_VF_MEM = _MAKE_CHAN(5, 0xFF, 1, 0xFF),    /*!< CSI to IC Viewfinder PreProcessing to Memory */
  168.     CSI_PRP_VF_ADC = _MAKE_CHAN(6, 0xFF, 1, 0xFF),    /*!< CSI to IC Viewfinder PreProcessing to ADC */
  169.     MEM_PRP_VF_MEM = _MAKE_CHAN(7, 6, 1, 3),    /*!< Memory to IC Viewfinder PreProcessing to Memory */
  170.     MEM_PRP_VF_ADC = _MAKE_CHAN(8, 6, 1, 3),    /*!< Memory to IC Viewfinder PreProcessing to ADC */
  171.     MEM_ROT_VF_MEM = _MAKE_CHAN(9, 11, 9, 0xFF),    /*!< Memory to IC Viewfinder Rotation to Memory */
  172.  
  173.     MEM_PP_MEM = _MAKE_CHAN(10, 5, 2, 4),    /*!< Memory to IC PostProcessing to Memory */
  174.     MEM_ROT_PP_MEM = _MAKE_CHAN(11, 13, 12, 0xFF),    /*!< Memory to IC PostProcessing Rotation to Memory */
  175.     MEM_PP_ADC = _MAKE_CHAN(12, 5, 2, 4),    /*!< Memory to IC PostProcessing to ADC */
  176.  
  177.     MEM_SDC_BG = _MAKE_CHAN(14, 14, 0xFF, 0xFF),    /*!< Memory to SDC Background plane */
  178.     MEM_SDC_FG = _MAKE_CHAN(15, 15, 0xFF, 0xFF),    /*!< Memory to SDC Foreground plane */
  179.     MEM_SDC_MASK = _MAKE_CHAN(16, 16, 0xFF, 0xFF),    /*!< Memory to SDC Mask */
  180.  
  181.     MEM_BG_SYNC = MEM_SDC_BG,
  182.     MEM_FG_SYNC = MEM_SDC_FG,
  183.  
  184.     ADC_SYS1 = _MAKE_CHAN(17, 18, 22, 20),    /*!< Memory to ADC System Channel 1 */
  185.     ADC_SYS2 = _MAKE_CHAN(18, 19, 23, 21),    /*!< Memory to ADC System Channel 2 */
  186.  
  187.     MEM_PF_Y_MEM = _MAKE_CHAN(19, 26, 29, 24),    /*!< Y and PF Memory to Post-filter to Y Memory */
  188.     MEM_PF_U_MEM = _MAKE_CHAN(20, 27, 30, 25),    /*!< U and PF Memory to Post-filter to U Memory */
  189.     MEM_PF_V_MEM = _MAKE_CHAN(21, 28, 31, 0xFF),    /*!< V Memory to Post-filter to V Memory */
  190.  
  191.     MEM_DC_SYNC = CHAN_NONE,
  192.     DIRECT_ASYNC0 = CHAN_NONE,
  193.     DIRECT_ASYNC1 = CHAN_NONE,
  194. #else
  195.     MEM_ROT_ENC_MEM = _MAKE_CHAN(1, 45, NO_DMA, NO_DMA, 48),
  196.     MEM_ROT_VF_MEM = _MAKE_CHAN(2, 46, NO_DMA, NO_DMA, 49),
  197.     MEM_ROT_PP_MEM = _MAKE_CHAN(3, 47, NO_DMA, NO_DMA, 50),
  198.  
  199.     MEM_PRP_ENC_MEM = _MAKE_CHAN(4, 12, 14, 17, 20),
  200.     MEM_PRP_VF_MEM = _MAKE_CHAN(5, 12, 14, 17, 21),
  201.     MEM_PP_MEM = _MAKE_CHAN(6, 11, 15, 18, 22),
  202.  
  203.     MEM_DC_SYNC = _MAKE_CHAN(7, 28, NO_DMA, NO_DMA, NO_DMA),
  204.     MEM_DC_ASYNC = _MAKE_CHAN(8, 41, NO_DMA, NO_DMA, NO_DMA),
  205.     MEM_BG_SYNC = _MAKE_CHAN(9, 23, NO_DMA, 51, NO_DMA),
  206.     MEM_FG_SYNC = _MAKE_CHAN(10, 27, NO_DMA, 31, NO_DMA),
  207.  
  208.     MEM_BG_ASYNC0 = _MAKE_CHAN(11, 24, NO_DMA, 52, NO_DMA),
  209.     MEM_FG_ASYNC0 = _MAKE_CHAN(12, 29, NO_DMA, 33, NO_DMA),
  210.     MEM_BG_ASYNC1 = _MAKE_ALT_CHAN(MEM_BG_ASYNC0),
  211.     MEM_FG_ASYNC1 = _MAKE_ALT_CHAN(MEM_FG_ASYNC0),
  212.  
  213.     DIRECT_ASYNC0 = _MAKE_CHAN(13, NO_DMA, NO_DMA, NO_DMA, NO_DMA),
  214.     DIRECT_ASYNC1 = _MAKE_CHAN(14, NO_DMA, NO_DMA, NO_DMA, NO_DMA),
  215.  
  216.     CSI_MEM0 = _MAKE_CHAN(15, NO_DMA, NO_DMA, NO_DMA, 0),
  217.     CSI_MEM1 = _MAKE_CHAN(16, NO_DMA, NO_DMA, NO_DMA, 1),
  218.     CSI_MEM2 = _MAKE_CHAN(17, NO_DMA, NO_DMA, NO_DMA, 2),
  219.     CSI_MEM3 = _MAKE_CHAN(18, NO_DMA, NO_DMA, NO_DMA, 3),
  220.  
  221.     CSI_MEM = CSI_MEM0,
  222.  
  223.     CSI_PRP_ENC_MEM = _MAKE_CHAN(19, NO_DMA, NO_DMA, NO_DMA, 20),
  224.     CSI_PRP_VF_MEM = _MAKE_CHAN(20, NO_DMA, NO_DMA, NO_DMA, 21),
  225.  
  226.     MEM_PP_ADC = CHAN_NONE,
  227.     ADC_SYS2 = CHAN_NONE,
  228. #endif
  229.  
  230. } ipu_channel_t;
  231.  
  232. /*!
  233.  * Enumeration of types of buffers for a logical channel.
  234.  */
  235. typedef enum {
  236.     IPU_OUTPUT_BUFFER = 0,    /*!< Buffer for output from IPU */
  237.     IPU_ALPHA_IN_BUFFER = 1,    /*!< Buffer for input to IPU */
  238.     IPU_GRAPH_IN_BUFFER = 2,    /*!< Buffer for input to IPU */
  239.     IPU_VIDEO_IN_BUFFER = 3,    /*!< Buffer for input to IPU */
  240.     IPU_INPUT_BUFFER = IPU_VIDEO_IN_BUFFER,
  241.     IPU_SEC_INPUT_BUFFER = IPU_GRAPH_IN_BUFFER,
  242. } ipu_buffer_t;
  243.  
  244. #define IPU_PANEL_SERIAL        1
  245. #define IPU_PANEL_PARALLEL        2
  246.  
  247. /*!
  248.  * Enumeration of DI ports for ADC.
  249.  */
  250. typedef enum {
  251.     DISP0,
  252.     DISP1,
  253.     DISP2,
  254.     DISP3
  255. } display_port_t;
  256.  
  257. /*!
  258.  * Enumeration of ADC channel operation mode.
  259.  */
  260. typedef enum {
  261.     Disable,
  262.     WriteTemplateNonSeq,
  263.     ReadTemplateNonSeq,
  264.     WriteTemplateUnCon,
  265.     ReadTemplateUnCon,
  266.     WriteDataWithRS,
  267.     WriteDataWoRS,
  268.     WriteCmd
  269. } mcu_mode_t;
  270.  
  271. /*!
  272.  * Enumeration of ADC channel addressing mode.
  273.  */
  274. typedef enum {
  275.     FullWoBE,
  276.     FullWithBE,
  277.     XY
  278. } display_addressing_t;
  279.  
  280. /*!
  281.  * Union of initialization parameters for a logical channel.
  282.  */
  283. typedef union {
  284.     struct {
  285.         uint32_t csi;
  286.         bool mipi_en;
  287.         uint32_t mipi_id;
  288.     } csi_mem;
  289.     struct {
  290.         uint32_t in_width;
  291.         uint32_t in_height;
  292.         uint32_t in_pixel_fmt;
  293.         uint32_t out_width;
  294.         uint32_t out_height;
  295.         uint32_t out_pixel_fmt;
  296.         uint32_t csi;
  297.     } csi_prp_enc_mem;
  298.     struct {
  299.         uint32_t in_width;
  300.         uint32_t in_height;
  301.         uint32_t in_pixel_fmt;
  302.         uint32_t out_width;
  303.         uint32_t out_height;
  304.         uint32_t out_pixel_fmt;
  305.     } mem_prp_enc_mem;
  306.     struct {
  307.         uint32_t in_width;
  308.         uint32_t in_height;
  309.         uint32_t in_pixel_fmt;
  310.         uint32_t out_width;
  311.         uint32_t out_height;
  312.         uint32_t out_pixel_fmt;
  313.     } mem_rot_enc_mem;
  314.     struct {
  315.         uint32_t in_width;
  316.         uint32_t in_height;
  317.         uint32_t in_pixel_fmt;
  318.         uint32_t out_width;
  319.         uint32_t out_height;
  320.         uint32_t out_pixel_fmt;
  321.         bool graphics_combine_en;
  322.         bool global_alpha_en;
  323.         bool key_color_en;
  324.         uint32_t csi;
  325.     } csi_prp_vf_mem;
  326.     struct {
  327.         uint32_t in_width;
  328.         uint32_t in_height;
  329.         uint32_t in_pixel_fmt;
  330.         uint32_t out_width;
  331.         uint32_t out_height;
  332.         uint32_t out_pixel_fmt;
  333.         bool graphics_combine_en;
  334.         bool global_alpha_en;
  335.         bool key_color_en;
  336.         display_port_t disp;
  337.         uint32_t out_left;
  338.         uint32_t out_top;
  339.     } csi_prp_vf_adc;
  340.     struct {
  341.         uint32_t in_width;
  342.         uint32_t in_height;
  343.         uint32_t in_pixel_fmt;
  344.         uint32_t out_width;
  345.         uint32_t out_height;
  346.         uint32_t out_pixel_fmt;
  347.         bool graphics_combine_en;
  348.         bool global_alpha_en;
  349.         bool key_color_en;
  350.     } mem_prp_vf_mem;
  351.     struct {
  352.         uint32_t temp;
  353.     } mem_prp_vf_adc;
  354.     struct {
  355.         uint32_t temp;
  356.     } mem_rot_vf_mem;
  357.     struct {
  358.         uint32_t in_width;
  359.         uint32_t in_height;
  360.         uint32_t in_pixel_fmt;
  361.         uint32_t out_width;
  362.         uint32_t out_height;
  363.         uint32_t out_pixel_fmt;
  364.         bool graphics_combine_en;
  365.         bool global_alpha_en;
  366.         bool key_color_en;
  367.     } mem_pp_mem;
  368.     struct {
  369.         uint32_t temp;
  370.     } mem_rot_mem;
  371.     struct {
  372.         uint32_t in_width;
  373.         uint32_t in_height;
  374.         uint32_t in_pixel_fmt;
  375.         uint32_t out_width;
  376.         uint32_t out_height;
  377.         uint32_t out_pixel_fmt;
  378.         bool graphics_combine_en;
  379.         bool global_alpha_en;
  380.         bool key_color_en;
  381.         display_port_t disp;
  382.         uint32_t out_left;
  383.         uint32_t out_top;
  384.     } mem_pp_adc;
  385.     struct {
  386.         pf_operation_t operation;
  387.     } mem_pf_mem;
  388.     struct {
  389.         uint32_t di;
  390.         bool interlaced;
  391.     } mem_dc_sync;
  392.     struct {
  393.         uint32_t temp;
  394.     } mem_sdc_fg;
  395.     struct {
  396.         uint32_t di;
  397.         bool interlaced;
  398.         uint32_t in_pixel_fmt;
  399.         uint32_t out_pixel_fmt;
  400.     } mem_dp_bg_sync;
  401.     struct {
  402.         uint32_t temp;
  403.     } mem_sdc_bg;
  404.     struct {
  405.         uint32_t di;
  406.         bool interlaced;
  407.         uint32_t in_pixel_fmt;
  408.         uint32_t out_pixel_fmt;
  409.     } mem_dp_fg_sync;
  410.     struct {
  411.         uint32_t di;
  412.     } direct_async;
  413.     struct {
  414.         display_port_t disp;
  415.         mcu_mode_t ch_mode;
  416.         uint32_t out_left;
  417.         uint32_t out_top;
  418.     } adc_sys1;
  419.     struct {
  420.         display_port_t disp;
  421.         mcu_mode_t ch_mode;
  422.         uint32_t out_left;
  423.         uint32_t out_top;
  424.     } adc_sys2;
  425. } ipu_channel_params_t;
  426.  
  427. /*!
  428.  * Enumeration of IPU interrupt sources.
  429.  */
  430. enum ipu_irq_line {
  431. #ifdef CONFIG_MXC_IPU_V1
  432.     IPU_IRQ_DC_FC_1 = -1,
  433.  
  434.     IPU_IRQ_PRP_ENC_OUT_EOF = 0,
  435.     IPU_IRQ_PRP_VF_OUT_EOF = 1,
  436.     IPU_IRQ_PP_OUT_EOF = 2,
  437.     IPU_IRQ_PRP_GRAPH_IN_EOF = 3,
  438.     IPU_IRQ_PP_GRAPH_IN_EOF = 4,
  439.     IPU_IRQ_PP_IN_EOF = 5,
  440.     IPU_IRQ_PRP_IN_EOF = 6,
  441.     IPU_IRQ_SENSOR_OUT_EOF = 7,
  442.     IPU_IRQ_PRP_ENC_ROT_OUT_EOF = 8,
  443.     IPU_IRQ_PRP_VF_ROT_OUT_EOF = 9,
  444.     IPU_IRQ_PRP_ENC_ROT_IN_EOF = 10,
  445.     IPU_IRQ_PRP_VF_ROT_IN_EOF = 11,
  446.     IPU_IRQ_PP_ROT_OUT_EOF = 12,
  447.     IPU_IRQ_PP_ROT_IN_EOF = 13,
  448.     IPU_IRQ_BG_SYNC_EOF = 14,
  449.     IPU_IRQ_SDC_BG_EOF = IPU_IRQ_BG_SYNC_EOF,
  450.     IPU_IRQ_FG_SYNC_EOF = 15,
  451.     IPU_IRQ_SDC_FG_EOF = IPU_IRQ_FG_SYNC_EOF,
  452.     IPU_IRQ_SDC_MASK_EOF = 16,
  453.     IPU_IRQ_SDC_BG_PART_EOF = 17,
  454.     IPU_IRQ_ADC_SYS1_WR_EOF = 18,
  455.     IPU_IRQ_ADC_SYS2_WR_EOF = 19,
  456.     IPU_IRQ_ADC_SYS1_CMD_EOF = 20,
  457.     IPU_IRQ_ADC_SYS2_CMD_EOF = 21,
  458.     IPU_IRQ_ADC_SYS1_RD_EOF = 22,
  459.     IPU_IRQ_ADC_SYS2_RD_EOF = 23,
  460.     IPU_IRQ_PF_QP_IN_EOF = 24,
  461.     IPU_IRQ_PF_BSP_IN_EOF = 25,
  462.     IPU_IRQ_PF_Y_IN_EOF = 26,
  463.     IPU_IRQ_PF_U_IN_EOF = 27,
  464.     IPU_IRQ_PF_V_IN_EOF = 28,
  465.     IPU_IRQ_PF_Y_OUT_EOF = 29,
  466.     IPU_IRQ_PF_U_OUT_EOF = 30,
  467.     IPU_IRQ_PF_V_OUT_EOF = 31,
  468.  
  469.     IPU_IRQ_PRP_ENC_OUT_NF = 32,
  470.     IPU_IRQ_PRP_VF_OUT_NF = 33,
  471.     IPU_IRQ_PP_OUT_NF = 34,
  472.     IPU_IRQ_PRP_GRAPH_IN_NF = 35,
  473.     IPU_IRQ_PP_GRAPH_IN_NF = 36,
  474.     IPU_IRQ_PP_IN_NF = 37,
  475.     IPU_IRQ_PRP_IN_NF = 38,
  476.     IPU_IRQ_SENSOR_OUT_NF = 39,
  477.     IPU_IRQ_PRP_ENC_ROT_OUT_NF = 40,
  478.     IPU_IRQ_PRP_VF_ROT_OUT_NF = 41,
  479.     IPU_IRQ_PRP_ENC_ROT_IN_NF = 42,
  480.     IPU_IRQ_PRP_VF_ROT_IN_NF = 43,
  481.     IPU_IRQ_PP_ROT_OUT_NF = 44,
  482.     IPU_IRQ_PP_ROT_IN_NF = 45,
  483.     IPU_IRQ_SDC_FG_NF = 46,
  484.     IPU_IRQ_SDC_BG_NF = 47,
  485.     IPU_IRQ_SDC_MASK_NF = 48,
  486.     IPU_IRQ_SDC_BG_PART_NF = 49,
  487.     IPU_IRQ_ADC_SYS1_WR_NF = 50,
  488.     IPU_IRQ_ADC_SYS2_WR_NF = 51,
  489.     IPU_IRQ_ADC_SYS1_CMD_NF = 52,
  490.     IPU_IRQ_ADC_SYS2_CMD_NF = 53,
  491.     IPU_IRQ_ADC_SYS1_RD_NF = 54,
  492.     IPU_IRQ_ADC_SYS2_RD_NF = 55,
  493.     IPU_IRQ_PF_QP_IN_NF = 56,
  494.     IPU_IRQ_PF_BSP_IN_NF = 57,
  495.     IPU_IRQ_PF_Y_IN_NF = 58,
  496.     IPU_IRQ_PF_U_IN_NF = 59,
  497.     IPU_IRQ_PF_V_IN_NF = 60,
  498.     IPU_IRQ_PF_Y_OUT_NF = 61,
  499.     IPU_IRQ_PF_U_OUT_NF = 62,
  500.     IPU_IRQ_PF_V_OUT_NF = 63,
  501.  
  502.     IPU_IRQ_BREAKRQ = 64,
  503.     IPU_IRQ_SDC_BG_OUT_EOF = 65,
  504.     IPU_IRQ_BG_SF_END = IPU_IRQ_SDC_BG_OUT_EOF,
  505.     IPU_IRQ_SDC_FG_OUT_EOF = 66,
  506.     IPU_IRQ_SDC_MASK_OUT_EOF = 67,
  507.     IPU_IRQ_ADC_SERIAL_DATA_OUT = 68,
  508.     IPU_IRQ_SENSOR_NF = 69,
  509.     IPU_IRQ_SENSOR_EOF = 70,
  510.     IPU_IRQ_SDC_DISP3_VSYNC = 80,
  511.     IPU_IRQ_ADC_DISP0_VSYNC = 81,
  512.     IPU_IRQ_ADC_DISP12_VSYNC = 82,
  513.     IPU_IRQ_ADC_PRP_EOF = 83,
  514.     IPU_IRQ_ADC_PP_EOF = 84,
  515.     IPU_IRQ_ADC_SYS1_EOF = 85,
  516.     IPU_IRQ_ADC_SYS2_EOF = 86,
  517.  
  518.     IPU_IRQ_PRP_ENC_OUT_NFB4EOF_ERR = 96,
  519.     IPU_IRQ_PRP_VF_OUT_NFB4EOF_ERR = 97,
  520.     IPU_IRQ_PP_OUT_NFB4EOF_ERR = 98,
  521.     IPU_IRQ_PRP_GRAPH_IN_NFB4EOF_ERR = 99,
  522.     IPU_IRQ_PP_GRAPH_IN_NFB4EOF_ERR = 100,
  523.     IPU_IRQ_PP_IN_NFB4EOF_ERR = 101,
  524.     IPU_IRQ_PRP_IN_NFB4EOF_ERR = 102,
  525.     IPU_IRQ_SENSOR_OUT_NFB4EOF_ERR = 103,
  526.     IPU_IRQ_PRP_ENC_ROT_OUT_NFB4EOF_ERR = 104,
  527.     IPU_IRQ_PRP_VF_ROT_OUT_NFB4EOF_ERR = 105,
  528.     IPU_IRQ_PRP_ENC_ROT_IN_NFB4EOF_ERR = 106,
  529.     IPU_IRQ_PRP_VF_ROT_IN_NFB4EOF_ERR = 107,
  530.     IPU_IRQ_PP_ROT_OUT_NFB4EOF_ERR = 108,
  531.     IPU_IRQ_PP_ROT_IN_NFB4EOF_ERR = 109,
  532.     IPU_IRQ_SDC_FG_NFB4EOF_ERR = 110,
  533.     IPU_IRQ_SDC_BG_NFB4EOF_ERR = 111,
  534.     IPU_IRQ_SDC_MASK_NFB4EOF_ERR = 112,
  535.     IPU_IRQ_SDC_BG_PART_NFB4EOF_ERR = 113,
  536.     IPU_IRQ_ADC_SYS1_WR_NFB4EOF_ERR = 114,
  537.     IPU_IRQ_ADC_SYS2_WR_NFB4EOF_ERR = 115,
  538.     IPU_IRQ_ADC_SYS1_CMD_NFB4EOF_ERR = 116,
  539.     IPU_IRQ_ADC_SYS2_CMD_NFB4EOF_ERR = 117,
  540.     IPU_IRQ_ADC_SYS1_RD_NFB4EOF_ERR = 118,
  541.     IPU_IRQ_ADC_SYS2_RD_NFB4EOF_ERR = 119,
  542.     IPU_IRQ_PF_QP_IN_NFB4EOF_ERR = 120,
  543.     IPU_IRQ_PF_BSP_IN_NFB4EOF_ERR = 121,
  544.     IPU_IRQ_PF_Y_IN_NFB4EOF_ERR = 122,
  545.     IPU_IRQ_PF_U_IN_NFB4EOF_ERR = 123,
  546.     IPU_IRQ_PF_V_IN_NFB4EOF_ERR = 124,
  547.     IPU_IRQ_PF_Y_OUT_NFB4EOF_ERR = 125,
  548.     IPU_IRQ_PF_U_OUT_NFB4EOF_ERR = 126,
  549.     IPU_IRQ_PF_V_OUT_NFB4EOF_ERR = 127,
  550.  
  551.     IPU_IRQ_BAYER_BUFOVF_ERR = 128,
  552.     IPU_IRQ_ENC_BUFOVF_ERR = 129,
  553.     IPU_IRQ_VF_BUFOVF_ERR = 130,
  554.     IPU_IRQ_ADC_PP_TEAR_ERR = 131,
  555.     IPU_IRQ_ADC_SYS1_TEAR_ERR = 132,
  556.     IPU_IRQ_ADC_SYS2_TEAR_ERR = 133,
  557.     IPU_IRQ_SDC_BGD_ERR = 134,
  558.     IPU_IRQ_SDC_FGD_ERR = 135,
  559.     IPU_IRQ_SDC_MASKD_ERR = 136,
  560.     IPU_IRQ_BAYER_FRM_LOST_ERR = 137,
  561.     IPU_IRQ_ENC_FRM_LOST_ERR = 138,
  562.     IPU_IRQ_VF_FRM_LOST_ERR = 139,
  563.     IPU_IRQ_ADC_LOCK_ERR = 140,
  564.     IPU_IRQ_DI_LLA_LOCK_ERR = 141,
  565.     IPU_IRQ_AHB_M1_ERR = 142,
  566.     IPU_IRQ_AHB_M12_ERR = 143,
  567. #else
  568.     IPU_IRQ_CSI0_OUT_EOF = 0,
  569.     IPU_IRQ_CSI1_OUT_EOF = 1,
  570.     IPU_IRQ_CSI2_OUT_EOF = 2,
  571.     IPU_IRQ_CSI3_OUT_EOF = 3,
  572.     IPU_IRQ_PP_IN_EOF = 11,
  573.     IPU_IRQ_PRP_IN_EOF = 12,
  574.     IPU_IRQ_PRP_GRAPH_IN_EOF = 14,
  575.     IPU_IRQ_PP_GRAPH_IN_EOF = 15,
  576.     IPU_IRQ_PRP_ALPHA_IN_EOF = 17,
  577.     IPU_IRQ_PP_ALPHA_IN_EOF = 18,
  578.     IPU_IRQ_PRP_ENC_OUT_EOF = 20,
  579.     IPU_IRQ_PRP_VF_OUT_EOF = 21,
  580.     IPU_IRQ_PP_OUT_EOF = 22,
  581.     IPU_IRQ_BG_SYNC_EOF = 23,
  582.     IPU_IRQ_BG_ASYNC_EOF = 24,
  583.     IPU_IRQ_FG_SYNC_EOF = 27,
  584.     IPU_IRQ_DC_SYNC_EOF = 28,
  585.     IPU_IRQ_FG_ASYNC_EOF = 29,
  586.     IPU_IRQ_FG_ALPHA_SYNC_EOF = 31,
  587.  
  588.     IPU_IRQ_FG_ALPHA_ASYNC_EOF = 33,
  589.     IPU_IRQ_DC_READ_EOF = 40,
  590.     IPU_IRQ_DC_ASYNC_EOF = 41,
  591.     IPU_IRQ_DC_CMD1_EOF = 42,
  592.     IPU_IRQ_DC_CMD2_EOF = 43,
  593.     IPU_IRQ_DC_MASK_EOF = 44,
  594.     IPU_IRQ_PRP_ENC_ROT_OUT_EOF = 45,
  595.     IPU_IRQ_PRP_VF_ROT_OUT_EOF = 46,
  596.     IPU_IRQ_PP_ROT_OUT_EOF = 47,
  597.     IPU_IRQ_PRP_ENC_ROT_IN_EOF = 48,
  598.     IPU_IRQ_PRP_VF_ROT_IN_EOF = 49,
  599.     IPU_IRQ_PP_ROT_IN_EOF = 50,
  600.     IPU_IRQ_BG_ALPHA_SYNC_EOF = 51,
  601.     IPU_IRQ_BG_ALPHA_ASYNC_EOF = 52,
  602.  
  603.     IPU_IRQ_DP_SF_START = 448 + 2,
  604.     IPU_IRQ_DP_SF_END = 448 + 3,
  605.     IPU_IRQ_BG_SF_END = IPU_IRQ_DP_SF_END,
  606.     IPU_IRQ_DC_FC_0 = 448 + 8,
  607.     IPU_IRQ_DC_FC_1 = 448 + 9,
  608.     IPU_IRQ_DC_FC_2 = 448 + 10,
  609.     IPU_IRQ_DC_FC_3 = 448 + 11,
  610.     IPU_IRQ_DC_FC_4 = 448 + 12,
  611.     IPU_IRQ_DC_FC_6 = 448 + 13,
  612.     IPU_IRQ_VSYNC_PRE_0 = 448 + 14,
  613.     IPU_IRQ_VSYNC_PRE_1 = 448 + 15,
  614. #endif
  615.  
  616.     IPU_IRQ_COUNT
  617. };
  618.  
  619. /*!
  620.  * Bitfield of Display Interface signal polarities.
  621.  */
  622. typedef struct {
  623.     unsigned datamask_en:1;
  624.     unsigned ext_clk:1;
  625.     unsigned interlaced:1;
  626.     unsigned odd_field_first:1;
  627.     unsigned clksel_en:1;
  628.     unsigned clkidle_en:1;
  629.     unsigned data_pol:1;    /* true = inverted */
  630.     unsigned clk_pol:1;    /* true = rising edge */
  631.     unsigned enable_pol:1;
  632.     unsigned Hsync_pol:1;    /* true = active high */
  633.     unsigned Vsync_pol:1;
  634. } ipu_di_signal_cfg_t;
  635.  
  636. /*!
  637.  * Bitfield of CSI signal polarities and modes.
  638.  */
  639.  
  640. typedef struct {
  641.     unsigned data_width:4;
  642.     unsigned clk_mode:3;
  643.     unsigned ext_vsync:1;
  644.     unsigned Vsync_pol:1;
  645.     unsigned Hsync_pol:1;
  646.     unsigned pixclk_pol:1;
  647.     unsigned data_pol:1;
  648.     unsigned sens_clksrc:1;
  649.     unsigned pack_tight:1;
  650.     unsigned force_eof:1;
  651.     unsigned data_en_pol:1;
  652.     unsigned data_fmt;
  653.     unsigned csi;
  654.     unsigned mclk;
  655. } ipu_csi_signal_cfg_t;
  656.  
  657. /*!
  658.  * Enumeration of CSI data bus widths.
  659.  */
  660. enum {
  661.     IPU_CSI_DATA_WIDTH_4,
  662.     IPU_CSI_DATA_WIDTH_8,
  663.     IPU_CSI_DATA_WIDTH_10,
  664.     IPU_CSI_DATA_WIDTH_16,
  665. };
  666.  
  667. /*!
  668.  * Enumeration of CSI clock modes.
  669.  */
  670. enum {
  671.     IPU_CSI_CLK_MODE_GATED_CLK,
  672.     IPU_CSI_CLK_MODE_NONGATED_CLK,
  673.     IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE,
  674.     IPU_CSI_CLK_MODE_CCIR656_INTERLACED,
  675.     IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR,
  676.     IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR,
  677.     IPU_CSI_CLK_MODE_CCIR1120_INTERLACED_DDR,
  678.     IPU_CSI_CLK_MODE_CCIR1120_INTERLACED_SDR,
  679. };
  680.  
  681. enum {
  682.     IPU_CSI_MIPI_DI0,
  683.     IPU_CSI_MIPI_DI1,
  684.     IPU_CSI_MIPI_DI2,
  685.     IPU_CSI_MIPI_DI3,
  686. };
  687.  
  688. typedef enum {
  689.     RGB,
  690.     YCbCr,
  691.     YUV
  692. } ipu_color_space_t;
  693.  
  694. /*!
  695.  * Enumeration of ADC vertical sync mode.
  696.  */
  697. typedef enum {
  698.     VsyncNone,
  699.     VsyncInternal,
  700.     VsyncCSI,
  701.     VsyncExternal
  702. } vsync_t;
  703.  
  704. typedef enum {
  705.     DAT,
  706.     CMD
  707. } cmddata_t;
  708.  
  709. /*!
  710.  * Enumeration of ADC display update mode.
  711.  */
  712. typedef enum {
  713.     IPU_ADC_REFRESH_NONE,
  714.     IPU_ADC_AUTO_REFRESH,
  715.     IPU_ADC_AUTO_REFRESH_SNOOP,
  716.     IPU_ADC_SNOOPING,
  717. } ipu_adc_update_mode_t;
  718.  
  719. /*!
  720.  * Enumeration of ADC display interface types (serial or parallel).
  721.  */
  722. enum {
  723.     IPU_ADC_IFC_MODE_SYS80_TYPE1,
  724.     IPU_ADC_IFC_MODE_SYS80_TYPE2,
  725.     IPU_ADC_IFC_MODE_SYS68K_TYPE1,
  726.     IPU_ADC_IFC_MODE_SYS68K_TYPE2,
  727.     IPU_ADC_IFC_MODE_3WIRE_SERIAL,
  728.     IPU_ADC_IFC_MODE_4WIRE_SERIAL,
  729.     IPU_ADC_IFC_MODE_5WIRE_SERIAL_CLK,
  730.     IPU_ADC_IFC_MODE_5WIRE_SERIAL_CS,
  731. };
  732.  
  733. enum {
  734.     IPU_ADC_IFC_WIDTH_8,
  735.     IPU_ADC_IFC_WIDTH_16,
  736. };
  737.  
  738. /*!
  739.  * Enumeration of ADC display interface burst mode.
  740.  */
  741. enum {
  742.     IPU_ADC_BURST_WCS,
  743.     IPU_ADC_BURST_WBLCK,
  744.     IPU_ADC_BURST_NONE,
  745.     IPU_ADC_BURST_SERIAL,
  746. };
  747.  
  748. /*!
  749.  * Enumeration of ADC display interface RW signal timing modes.
  750.  */
  751. enum {
  752.     IPU_ADC_SER_NO_RW,
  753.     IPU_ADC_SER_RW_BEFORE_RS,
  754.     IPU_ADC_SER_RW_AFTER_RS,
  755. };
  756.  
  757. /*!
  758.  * Bitfield of ADC signal polarities and modes.
  759.  */
  760. typedef struct {
  761.     unsigned data_pol:1;
  762.     unsigned clk_pol:1;
  763.     unsigned cs_pol:1;
  764.     unsigned rs_pol:1;
  765.     unsigned addr_pol:1;
  766.     unsigned read_pol:1;
  767.     unsigned write_pol:1;
  768.     unsigned Vsync_pol:1;
  769.     unsigned burst_pol:1;
  770.     unsigned burst_mode:2;
  771.     unsigned ifc_mode:3;
  772.     unsigned ifc_width:5;
  773.     unsigned ser_preamble_len:4;
  774.     unsigned ser_preamble:8;
  775.     unsigned ser_rw_mode:2;
  776. } ipu_adc_sig_cfg_t;
  777.  
  778. /*!
  779.  * Enumeration of ADC template commands.
  780.  */
  781. enum {
  782.     RD_DATA,
  783.     RD_ACK,
  784.     RD_WAIT,
  785.     WR_XADDR,
  786.     WR_YADDR,
  787.     WR_ADDR,
  788.     WR_CMND,
  789.     WR_DATA,
  790. };
  791.  
  792. /*!
  793.  * Enumeration of ADC template command flow control.
  794.  */
  795. enum {
  796.     SINGLE_STEP,
  797.     PAUSE,
  798.     STOP,
  799. };
  800.  
  801. /*Define template constants*/
  802. #define     ATM_ADDR_RANGE      0x20    /*offset address of DISP */
  803. #define     TEMPLATE_BUF_SIZE   0x20    /*size of template */
  804.  
  805. /*!
  806.  * Define to create ADC template command entry.
  807.  */
  808. #define ipu_adc_template_gen(oc, rs, fc, dat) ( ((rs) << 29) | ((fc) << 27) | \
  809.                                                 ((oc) << 24) | (dat) )
  810.  
  811. typedef struct {
  812.     u32 reg;
  813.     u32 value;
  814. } ipu_lpmc_reg_t;
  815.  
  816. #define IPU_LPMC_REG_READ       0x80000000L
  817.  
  818. #define CSI_MCLK_VF  1
  819. #define CSI_MCLK_ENC 2
  820. #define CSI_MCLK_RAW 4
  821. #define CSI_MCLK_I2C 8
  822.  
  823. /* Common IPU API */
  824. int32_t ipu_init_channel(ipu_channel_t channel, ipu_channel_params_t * params);
  825. void ipu_uninit_channel(ipu_channel_t channel);
  826.  
  827. static inline bool ipu_can_rotate_in_place(ipu_rotate_mode_t rot)
  828. {
  829. #ifdef CONFIG_MXC_IPU_V3D
  830.     return (rot < IPU_ROTATE_HORIZ_FLIP);
  831. #else
  832.     return (rot < IPU_ROTATE_90_RIGHT);
  833. #endif
  834. }
  835.  
  836. int32_t ipu_init_channel_buffer(ipu_channel_t channel, ipu_buffer_t type,
  837.                 uint32_t pixel_fmt,
  838.                 uint16_t width, uint16_t height,
  839.                 uint32_t stride,
  840.                 ipu_rotate_mode_t rot_mode,
  841.                 dma_addr_t phyaddr_0, dma_addr_t phyaddr_1,
  842.                 uint32_t u_offset, uint32_t v_offset);
  843.  
  844. int32_t ipu_update_channel_buffer(ipu_channel_t channel, ipu_buffer_t type,
  845.                   uint32_t bufNum, dma_addr_t phyaddr);
  846.  
  847. int32_t ipu_select_buffer(ipu_channel_t channel,
  848.               ipu_buffer_t type, uint32_t bufNum);
  849.  
  850. int32_t ipu_link_channels(ipu_channel_t src_ch, ipu_channel_t dest_ch);
  851. int32_t ipu_unlink_channels(ipu_channel_t src_ch, ipu_channel_t dest_ch);
  852.  
  853. int32_t ipu_enable_channel(ipu_channel_t channel);
  854. int32_t ipu_disable_channel(ipu_channel_t channel, bool wait_for_stop);
  855.  
  856. int ipu_lowpwr_display_enable(void);
  857. int ipu_lowpwr_display_disable(void);
  858.  
  859. void ipu_enable_irq(uint32_t irq);
  860. void ipu_disable_irq(uint32_t irq);
  861. void ipu_clear_irq(uint32_t irq);
  862. int ipu_request_irq(uint32_t irq,
  863.             irqreturn_t(*handler) (int, void *),
  864.             uint32_t irq_flags, const char *devname, void *dev_id);
  865. void ipu_free_irq(uint32_t irq, void *dev_id);
  866. bool ipu_get_irq_status(uint32_t irq);
  867. void ipu_set_csc_coefficients(ipu_channel_t channel, int32_t param[][3]);
  868.  
  869. /* SDC API */
  870. int32_t ipu_sdc_init_panel(ipu_panel_t panel,
  871.                uint32_t pixel_clk,
  872.                uint16_t width, uint16_t height,
  873.                uint32_t pixel_fmt,
  874.                uint16_t hStartWidth, uint16_t hSyncWidth,
  875.                uint16_t hEndWidth, uint16_t vStartWidth,
  876.                uint16_t vSyncWidth, uint16_t vEndWidth,
  877.                ipu_di_signal_cfg_t sig);
  878.  
  879. int32_t ipu_sdc_set_global_alpha(bool enable, uint8_t alpha);
  880. int32_t ipu_sdc_set_color_key(ipu_channel_t channel, bool enable,
  881.                   uint32_t colorKey);
  882. int32_t ipu_sdc_set_brightness(uint8_t value);
  883.  
  884. int32_t ipu_init_sync_panel(int disp,
  885.                 uint32_t pixel_clk,
  886.                 uint16_t width, uint16_t height,
  887.                 uint32_t pixel_fmt,
  888.                 uint16_t h_start_width, uint16_t h_sync_width,
  889.                 uint16_t h_end_width, uint16_t v_start_width,
  890.                 uint16_t v_sync_width, uint16_t v_end_width,
  891.                 uint32_t v_to_h_sync, ipu_di_signal_cfg_t sig);
  892.  
  893. int32_t ipu_disp_set_window_pos(ipu_channel_t channel, int16_t x_pos,
  894.                 int16_t y_pos);
  895. int32_t ipu_disp_set_global_alpha(ipu_channel_t channel, bool enable,
  896.                   uint8_t alpha);
  897. int32_t ipu_disp_set_color_key(ipu_channel_t channel, bool enable,
  898.                    uint32_t colorKey);
  899.  
  900. int ipu_init_async_panel(int disp, int type, uint32_t cycle_time,
  901.              uint32_t pixel_fmt, ipu_adc_sig_cfg_t sig);
  902. void ipu_disp_direct_write(ipu_channel_t channel, u32 value, u32 offset);
  903. void ipu_reset_disp_panel(void);
  904.  
  905. /* ADC API */
  906. int32_t ipu_adc_write_template(display_port_t disp, uint32_t * pCmd,
  907.                    bool write);
  908.  
  909. int32_t ipu_adc_set_update_mode(ipu_channel_t channel,
  910.                 ipu_adc_update_mode_t mode,
  911.                 uint32_t refresh_rate, unsigned long addr,
  912.                 uint32_t * size);
  913.  
  914. int32_t ipu_adc_get_snooping_status(uint32_t * statl, uint32_t * stath);
  915.  
  916. int32_t ipu_adc_write_cmd(display_port_t disp, cmddata_t type,
  917.               uint32_t cmd, const uint32_t * params,
  918.               uint16_t numParams);
  919.  
  920. int32_t ipu_adc_init_panel(display_port_t disp,
  921.                uint16_t width, uint16_t height,
  922.                uint32_t pixel_fmt,
  923.                uint32_t stride,
  924.                ipu_adc_sig_cfg_t sig,
  925.                display_addressing_t addr,
  926.                uint32_t vsync_width, vsync_t mode);
  927.  
  928. int32_t ipu_adc_init_ifc_timing(display_port_t disp, bool read,
  929.                 uint32_t cycle_time,
  930.                 uint32_t up_time,
  931.                 uint32_t down_time,
  932.                 uint32_t read_latch_time, uint32_t pixel_clk);
  933.  
  934. /* CMOS Sensor Interface API */
  935. int32_t ipu_csi_init_interface(uint16_t width, uint16_t height,
  936.                    uint32_t pixel_fmt, ipu_csi_signal_cfg_t sig);
  937.  
  938. int32_t ipu_csi_enable_mclk(int src, bool flag, bool wait);
  939.  
  940. static inline int32_t ipu_csi_enable_mclk_if(int src, uint32_t csi,
  941.         bool flag, bool wait)
  942. {
  943. #ifdef CONFIG_MXC_IPU_V1
  944.     return ipu_csi_enable_mclk(src, flag, wait);
  945. #else
  946.     return ipu_csi_enable_mclk(csi, flag, wait);
  947. #endif
  948. }
  949.  
  950. int ipu_csi_read_mclk_flag(void);
  951.  
  952. void ipu_csi_flash_strobe(bool flag);
  953.  
  954. void ipu_csi_get_window_size(uint32_t *width, uint32_t *height, uint32_t csi);
  955.  
  956. void ipu_csi_set_window_size(uint32_t width, uint32_t height, uint32_t csi);
  957.  
  958. void ipu_csi_set_window_pos(uint32_t left, uint32_t top, uint32_t csi);
  959.  
  960. /* Post Filter functions */
  961. int32_t ipu_pf_set_pause_row(uint32_t pause_row);
  962.  
  963. uint32_t bytes_per_pixel(uint32_t fmt);
  964.  
  965. /* New added for IPU-lib functionality*/
  966. int ipu_open(void);
  967. int ipu_register_generic_isr(int irq, void *dev);
  968. void ipu_close(void);
  969.  
  970. typedef struct _ipu_channel_parm {
  971.     ipu_channel_t channel;
  972.     ipu_channel_params_t params;
  973.     bool flag;
  974. } ipu_channel_parm;
  975.  
  976. typedef struct _ipu_channel_buf_parm {
  977.     ipu_channel_t channel;
  978.     ipu_buffer_t type;
  979.     uint32_t pixel_fmt;
  980.     uint16_t width;
  981.     uint16_t height;
  982.     uint16_t stride;
  983.     ipu_rotate_mode_t rot_mode;
  984.     dma_addr_t phyaddr_0;
  985.     dma_addr_t phyaddr_1;
  986.     uint32_t u_offset;
  987.     uint32_t v_offset;
  988.     uint32_t bufNum;
  989. } ipu_channel_buf_parm;
  990.  
  991. typedef struct _ipu_channel_link {
  992.     ipu_channel_t src_ch;
  993.     ipu_channel_t dest_ch;
  994. } ipu_channel_link;
  995.  
  996. typedef struct _ipu_channel_info {
  997.     ipu_channel_t channel;
  998.     bool stop;
  999. } ipu_channel_info;
  1000.  
  1001. typedef struct ipu_irq_info {
  1002.     uint32_t irq;
  1003.      irqreturn_t(*handler) (int, void *);
  1004.     uint32_t irq_flags;
  1005.     char *devname;
  1006.     void *dev_id;
  1007. } ipu_irq_info;
  1008.  
  1009. typedef struct _ipu_sdc_panel_info {
  1010.     ipu_panel_t panel;
  1011.     uint32_t pixel_clk;
  1012.     uint16_t width;
  1013.     uint16_t height;
  1014.     uint32_t pixel_fmt;
  1015.     uint16_t hStartWidth;
  1016.     uint16_t hSyncWidth;
  1017.     uint16_t hEndWidth;
  1018.     uint16_t vStartWidth;
  1019.     uint16_t vSyncWidth;
  1020.     uint16_t vEndWidth;
  1021.     ipu_di_signal_cfg_t signal;
  1022. } ipu_sdc_panel_info;
  1023.  
  1024. typedef struct _ipu_sdc_window_pos {
  1025.     ipu_channel_t channel;
  1026.     int16_t x_pos;
  1027.     int16_t y_pos;
  1028. } ipu_sdc_window_pos;
  1029.  
  1030. typedef struct _ipu_sdc_global_alpha {
  1031.     bool enable;
  1032.     uint8_t alpha;
  1033. } ipu_sdc_global_alpha;
  1034.  
  1035. typedef struct _ipu_sdc_color_key {
  1036.     ipu_channel_t channel;
  1037.     bool enable;
  1038.     uint32_t colorKey;
  1039. } ipu_sdc_color_key;
  1040.  
  1041. typedef struct _ipu_adc_template {
  1042.     display_port_t disp;
  1043.     uint32_t *pCmd;
  1044.     bool write;
  1045. } ipu_adc_template;
  1046.  
  1047. typedef struct _ipu_adc_update {
  1048.     ipu_channel_t channel;
  1049.     ipu_adc_update_mode_t mode;
  1050.     uint32_t refresh_rate;
  1051.     unsigned long addr;
  1052.     uint32_t *size;
  1053. } ipu_adc_update;
  1054.  
  1055. typedef struct _ipu_adc_snoop {
  1056.     uint32_t *statl;
  1057.     uint32_t *stath;
  1058. } ipu_adc_snoop;
  1059.  
  1060. typedef struct _ipu_adc_cmd {
  1061.     display_port_t disp;
  1062.     cmddata_t type;
  1063.     uint32_t cmd;
  1064.     uint32_t *params;
  1065.     uint16_t numParams;
  1066. } ipu_adc_cmd;
  1067.  
  1068. typedef struct _ipu_adc_panel {
  1069.     display_port_t disp;
  1070.     uint16_t width;
  1071.     uint16_t height;
  1072.     uint32_t pixel_fmt;
  1073.     uint32_t stride;
  1074.     ipu_adc_sig_cfg_t signal;
  1075.     display_addressing_t addr;
  1076.     uint32_t vsync_width;
  1077.     vsync_t mode;
  1078. } ipu_adc_panel;
  1079.  
  1080. typedef struct _ipu_adc_ifc_timing {
  1081.     display_port_t disp;
  1082.     bool read;
  1083.     uint32_t cycle_time;
  1084.     uint32_t up_time;
  1085.     uint32_t down_time;
  1086.     uint32_t read_latch_time;
  1087.     uint32_t pixel_clk;
  1088. } ipu_adc_ifc_timing;
  1089.  
  1090. typedef struct _ipu_csi_interface {
  1091.     uint16_t width;
  1092.     uint16_t height;
  1093.     uint16_t pixel_fmt;
  1094.     ipu_csi_signal_cfg_t signal;
  1095. } ipu_csi_interface;
  1096.  
  1097. typedef struct _ipu_csi_mclk {
  1098.     int src;
  1099.     bool flag;
  1100.     bool wait;
  1101. } ipu_csi_mclk;
  1102.  
  1103. typedef struct _ipu_csi_window {
  1104.     uint32_t left;
  1105.     uint32_t top;
  1106. } ipu_csi_window;
  1107.  
  1108. typedef struct _ipu_csi_window_size {
  1109.     uint32_t width;
  1110.     uint32_t height;
  1111. } ipu_csi_window_size;
  1112.  
  1113. typedef struct _ipu_event_info {
  1114.     int irq;
  1115.     void *dev;
  1116. } ipu_event_info;
  1117.  
  1118. typedef struct _ipu_mem_info {
  1119.     dma_addr_t paddr;
  1120.     void *vaddr;
  1121.     int size;
  1122. } ipu_mem_info;
  1123.  
  1124. /* IOCTL commands */
  1125.  
  1126. #define IPU_INIT_CHANNEL              _IOW('I',0x1,ipu_channel_parm)
  1127. #define IPU_UNINIT_CHANNEL            _IOW('I',0x2,ipu_channel_t)
  1128. #define IPU_INIT_CHANNEL_BUFFER       _IOW('I',0x3,ipu_channel_buf_parm)
  1129. #define IPU_UPDATE_CHANNEL_BUFFER     _IOW('I',0x4,ipu_channel_buf_parm)
  1130. #define IPU_SELECT_CHANNEL_BUFFER     _IOW('I',0x5,ipu_channel_buf_parm)
  1131. #define IPU_LINK_CHANNELS             _IOW('I',0x6,ipu_channel_link)
  1132. #define IPU_UNLINK_CHANNELS           _IOW('I',0x7,ipu_channel_link)
  1133. #define IPU_ENABLE_CHANNEL            _IOW('I',0x8,ipu_channel_t)
  1134. #define IPU_DISABLE_CHANNEL           _IOW('I',0x9,ipu_channel_info)
  1135. #define IPU_ENABLE_IRQ                _IOW('I',0xA,int)
  1136. #define IPU_DISABLE_IRQ               _IOW('I',0xB,int)
  1137. #define IPU_CLEAR_IRQ                 _IOW('I',0xC,int)
  1138. #define IPU_FREE_IRQ                  _IOW('I',0xD,ipu_irq_info)
  1139. #define IPU_REQUEST_IRQ_STATUS        _IOW('I',0xE,int)
  1140. #define IPU_SDC_INIT_PANEL            _IOW('I',0xF,ipu_sdc_panel_info)
  1141. #define IPU_SDC_SET_WIN_POS           _IOW('I',0x10,ipu_sdc_window_pos)
  1142. #define IPU_SDC_SET_GLOBAL_ALPHA      _IOW('I',0x11,ipu_sdc_global_alpha)
  1143. #define IPU_SDC_SET_COLOR_KEY         _IOW('I',0x12,ipu_sdc_color_key)
  1144. #define IPU_SDC_SET_BRIGHTNESS        _IOW('I',0x13,int)
  1145. #define IPU_ADC_WRITE_TEMPLATE        _IOW('I',0x14,ipu_adc_template)
  1146. #define IPU_ADC_UPDATE                _IOW('I',0x15,ipu_adc_update)
  1147. #define IPU_ADC_SNOOP                 _IOW('I',0x16,ipu_adc_snoop)
  1148. #define IPU_ADC_CMD                   _IOW('I',0x17,ipu_adc_cmd)
  1149. #define IPU_ADC_INIT_PANEL            _IOW('I',0x18,ipu_adc_panel)
  1150. #define IPU_ADC_IFC_TIMING            _IOW('I',0x19,ipu_adc_ifc_timing)
  1151. #define IPU_CSI_INIT_INTERFACE        _IOW('I',0x1A,ipu_csi_interface)
  1152. #define IPU_CSI_ENABLE_MCLK           _IOW('I',0x1B,ipu_csi_mclk)
  1153. #define IPU_CSI_READ_MCLK_FLAG        _IOR('I',0x1C,ipu_csi_mclk)
  1154. #define IPU_CSI_FLASH_STROBE          _IOW('I',0x1D,ipu_csi_mclk)
  1155. #define IPU_CSI_GET_WIN_SIZE          _IOR('I',0x1E,ipu_csi_window_size)
  1156. #define IPU_CSI_SET_WIN_SIZE          _IOW('I',0x1F,ipu_csi_window_size)
  1157. #define IPU_CSI_SET_WINDOW            _IOW('I',0x20,ipu_csi_window)
  1158. #define IPU_PF_SET_PAUSE_ROW          _IOW('I',0x21, uint32_t)
  1159. #define IPU_REGISTER_GENERIC_ISR      _IOW('I',0x22,ipu_event_info)
  1160. #define IPU_GET_EVENT                 _IOR('I',0x23,ipu_event_info)
  1161. #define IPU_ALOC_MEM              _IOWR('I', 0x24, ipu_mem_info)
  1162. #define IPU_FREE_MEM              _IOW('I', 0x25, ipu_mem_info)
  1163.  
  1164. #endif
  1165.